import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;

import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author: lvliangjun
 * @Date: 2024/5/24 10:06
 */
public class 解析镇坐标 {
    public static void main(String[] args) {
        //读取resources 下的 grid.txt
        String jsonString = "{\n" +
                "  \"success\": true,\n" +
                "  \"code\": 1,\n" +
                "  \"data\": {\n" +
                "    \"currentPage\": 1,\n" +
                "    \"hasMore\": 0,\n" +
                "    \"latestTimestamp\": 1717056807334,\n" +
                "    \"resourceCount\": 13,\n" +
                "    \"resourceList\": [\n" +
                "      {\n" +
                "        \"approvalStatus\": 1,\n" +
                "        \"categoryId\": \"4009182133646874\",\n" +
                "        \"createUserId\": \"537102874\",\n" +
                "        \"createUserName\": \"梁黎望\",\n" +
                "        \"iconFiller\": \"15\",\n" +
                "        \"iconFillerInfo\": {\n" +
                "          \"iconFillerId\": \"15\",\n" +
                "          \"iconFillerShowType\": 3,\n" +
                "          \"iconFillerValue\": \"15\"\n" +
                "        },\n" +
                "        \"iconOutline\": \"1\",\n" +
                "        \"imageList\": [\n" +
                "          \"https://track-record-file-base.amap.com/b9fba5cfebc1686deb34ad849365c89e/snapshot_temp_1_thumb.jpeg\",\n" +
                "          \"https://track-record-file-base.amap.com/d2ade889618d0d914486e0a4e3b79bdd/snapshot_temp_3_thumb.jpeg\"\n" +
                "        ],\n" +
                "        \"missionList\": [],\n" +
                "        \"modifiedTime\": 1716861431656,\n" +
                "        \"parentCategoryDTOList\": [\n" +
                "          {\n" +
                "            \"categoryId\": \"4009182133649842\",\n" +
                "            \"categoryLevel\": 1,\n" +
                "            \"categoryTitle\": \"尽调现场记录\"\n" +
                "          }\n" +
                "        ],\n" +
                "        \"poiSecretType\": -1,\n" +
                "        \"pointInfo\": {\n" +
                "          \"originalName\": \"乾县107省道\",\n" +
                "          \"address\": \"陕西省咸阳市乾县107省道\",\n" +
                "          \"province\": \"陕西省\",\n" +
                "          \"city\": \"咸阳市\",\n" +
                "          \"latitude\": 34.514604894953,\n" +
                "          \"district\": \"乾县\",\n" +
                "          \"name\": \"乾县107省道\",\n" +
                "          \"isMyLocationTag\": true,\n" +
                "          \"lon\": 108.14797134110034,\n" +
                "          \"lat\": 34.514604894953,\n" +
                "          \"longitude\": 108.14797134110034\n" +
                "        },\n" +
                "        \"resourceColor\": \"#00FF12,#00CC0E\",\n" +
                "        \"resourceId\": \"200918213654524519\",\n" +
                "        \"resourceName\": \"乾县邓建峰种养殖农民专业合作社\",\n" +
                "        \"resourceStatus\": 1,\n" +
                "        \"resourceType\": 1,\n" +
                "        \"showImageSwitch\": 2,\n" +
                "        \"sortNum\": null,\n" +
                "        \"subResourceId\": \"300918213637055257\",\n" +
                "        \"workMissionId\": \"\",\n" +
                "        \"workTaskFinishStatus\": null,\n" +
                "        \"workTaskId\": \"\"\n" +
                "      }\n" +
                "    ]\n" +
                "  },\n" +
                "  \"describe\": \"\",\n" +
                "  \"message\": \"Successful\",\n" +
                "  \"result\": true,\n" +
                "  \"timestamp\": 1717056816578,\n" +
                "  \"traceId\": \"2136773117170568164532123e2249\",\n" +
                "  \"version\": \"1.0\"\n" +
                "}";
        JSONObject jsonObject = JSONUtil.parseObj(jsonString);
        JSONObject data = jsonObject.getJSONObject("data");
        JSONArray jsonArray = data.getJSONArray("resourceList");
        for (Object o : jsonArray) {
            JSONObject jsonObject1 = (JSONObject) o;
            JSONObject pointInfo = jsonObject1.getJSONObject("pointInfo");

            double lat = pointInfo.getDouble("lat");
            double lon = pointInfo.getDouble("lon");
            String address = pointInfo.getStr("address");
            String resourceName = jsonObject1.getStr("resourceName");
            System.out.println("Latitude: " + lat);
            System.out.println("Longitude: " + lon);
            System.out.println("resourceName: " + resourceName);
            System.out.println("address: " + address);
        }
//
//        JSONObject resourceList = jsonArray.getJSONObject(0);
//        JSONObject pointInfo = resourceList.getJSONObject("pointInfo");
//
//        double lat = pointInfo.getDouble("lat");
//        double lon = pointInfo.getDouble("lon");
//
//        System.out.println("Latitude: " + lat);
//        System.out.println("Longitude: " + lon);
    }

}
